package com.svms.save.services.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.svms.save.cache.PublicCache;
import com.svms.save.entitys.SvdaZwxxx;
import com.svms.save.importexcel.service.TestTools;
import com.svms.save.importexcel.vo.FieldMapping;
import com.svms.save.services.SvdaZwxxxService;
import com.svms.save.utils.SysCode;

import jxl.Cell;

@Component
public class SvdaTestToolsManager extends TestTools {
	@Autowired
	private SvdaZwxxxService zwxxxManager;
	@Override
	public boolean dicTest(String dicName, String value) {
		// TODO Auto-generated method stub
		String zddm = PublicCache.getZddmByZdmc(dicName, value);
		if(null != zddm) {
			return true;
		}
		return false;
	}
	
	@Override
	public String otherTest(FieldMapping fm, String value, Cell[] cells) {
		// TODO Auto-generated method stub
		String wzbh = cells[4]==null?"":cells[4].getContents();
		String zwgbh = cells[5]==null?"":cells[5].getContents();
		String cgsbh = cells[6]==null?"":cells[6].getContents();
		String csbh = cells[7]==null?"":cells[7].getContents();
		String bh = zwxxxManager.genZwxwzbh(wzbh, zwgbh, csbh, cgsbh);
		SvdaZwxxx zwxxx = zwxxxManager.getZwxxxByZwxwzbh(bh);
		String zwxmc = PublicCache.getZdmcByLxjpZddm(SysCode.ZWX_ZD, bh, false);
		if(null != zwxxx && StringUtils.isNotBlank(zwxmc)) {
			return "";
		}
		String wzxx = zwxxxManager.tranZwxbh(bh);
		return String.format("在系统内未找到%s存储位置！", wzxx);
	}
}
